package com.epoint.mobileoa.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class DBOpenHelp extends SQLiteOpenHelper{

	public static final int VERSION = 1;

	public DBOpenHelp(Context context, String name, CursorFactory factory,
			int version) {
		super(context, name, factory, version);
	}

	public DBOpenHelp(Context context, String name) {
		this(context, name, VERSION);
	}

	public DBOpenHelp(Context context, String name,
			int version) {
		this(context, name, null, version);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		//二进制资源表
		db.execSQL("create table res(" +
				"key nvarchar," +
				"value blob" +
				")");

		//配置表
		db.execSQL("create table config(" +
				"key nvarchar," +
				"value nvarchar" +
				")");

		//用户表
		db.execSQL("create table user(" +
				"loginid nvarchar," +
				"userguid nvarchar," +
				"ouguid nvarchar," +
				"displayname nvarchar," +
				"mobile nvarchar," +
				"telephoneoffice nvarchar," +
				"title nvarchar," +
				"description nvarchar," +
				"fax nvarchar,"+
				"sex nvarchar," +
				"email nvarchar," +
				"telephonehome nvarchar," +
				"shortmobile nvarchar," +
				"qqnumber nvarchar," +
				"ntxextnumber nvarchar," +
				"namepyshou nvarchar" +
				")");

		//部门表
		db.execSQL("create table ou(" +
				"ouguid nvarchar," +
				"ouname nvarchar," +
				"parentguid nvarchar," +
				"namepyshou nvarchar" +
				")");

		//草稿箱
		db.execSQL("create table maildraft("+
				"draftguid nvarchar," +
				"mailtitle nvarchar," +
				"draftsavetime nvarchar," +
				"sendername nvarchar," +
				"senderguid nvarchar," +
				"receivername nvarchar," +
				"receiveguid nvarchar," +
				"chaosongrename nvarchar," +
				"chaosongrenguid nvarchar," +
				"mailcontent nvarchar," +
				"hasattach nvarchar," +
				"attachname nvarchar," +
				"attachpath nvarchar" +
				")");
		//登陆历史记录
		db.execSQL("create table login_history(loginid nvarchar,lastlogindate nvarchar)");
		
		//代码项
		db.execSQL("create table code_items(ItemValue nvarchar,ItemText nvarchar,ItemID nvarchar,CodeID nvarchar,CodeName nvarchar)");
	}
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		
	}

}
